﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Admin.Page_AdvTools
{
    public partial class RewriteEditor : Evan.WebUI.ManagerPage
    {
        protected string RewriteType = "system";
        protected string RewriteTypeString = "系统";
        protected string FileContent = "";
        protected string FilePath = "/App_Data/SysConfig/url_{0}.config";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //仅仅只有超级管理员拥有此功能
                if (!Evan.Member.Administrator.IsSuperAdmin())
                {
                    VerifyRoles();
                }
                string rt_config = Evan.Common.CommFun.GetAppSetting("Customer_UrlRewrite");
                if (Convert.ToInt32(rt_config)==1)
                {
                    RewriteType = "custom";
                    RewriteTypeString = "自定义";
                }
                if (Convert.ToInt32(rt_config) == 0)
                {
                    RewriteType = "system";
                    RewriteTypeString = "系统";
                }
                FilePath = string.Format(FilePath, RewriteType);
                FileContent = Evan.Common.DirFile.ReadFile(FilePath);
#if false
                //检查参数是否正确
                string rt = Evan.Common.CommFun.GetQueryString("rt");
                if (string.IsNullOrEmpty(rt))
                {
                    throw new Exception("编辑伪静态类型无法识别 , 请重新登录后再试");
                }

                if (rt == "system")
                {
                    RewriteType = "system";
                    RewriteTypeString = "系统";
                }
                else if (rt == "custom")
                {
                    RewriteType = "custom";
                    RewriteTypeString = "自定义";
                }
                else
                {
                    throw new Exception("编辑伪静态类型无法识别 , 请重新登录后再试");
                }

                FilePath = string.Format(FilePath, RewriteType);
#endif

            }
        }

    }
}